﻿//测试mysql接口
//主路由
let express = require("express"); //绝对路径
// let query = require("../db/mysql");
//引入子路由
let userRouter = require("./modules/users"); //用户管理子路由
// let wechatRouter = require("./modules/wechat"); //用户管理子路由
//创建路由对象
let Router = express.Router(); //Router==app

Router.use(express.urlencoded()); //处理name=马源123&age=18
Router.use(express.json()); //处理json数据  '{name:王祖贤,age:18}'


Router.use("/user", userRouter); //用户管理子路由
// Router.use("/wechat", wechatRouter); //用户管理子路由


//小程序接口
//1.获取图片列表
Router.get("/getimgs", async (req, res) => {
  let imgArr = ['https://img.alicdn.com/tfs/TB1FjZ7VWL7gK0jSZFBXXXZZpXa-520-280.png', 'https://aecpm.alicdn.com/imgextra/i4/240575018/O1CN01eSNp8b1mwI8iKklnI_!!240575018-0-alimamazszw.jpg', 'https://aecpm.alicdn.com/imgextra/i3/2137113794/O1CN01rW9Fzj1dthLx88imz_!!2137113794-0-alimamazszw.jpg'];
  res.send(imgArr); //响应数据给前端
});
//2.获取图片列表2
Router.get("/getBanner", async (req, res) => {
  let data = {
    code : 200,
    msg : '成功',
    data : [{
      id : 1,
      url : 'https://img.alicdn.com/tfs/TB1FjZ7VWL7gK0jSZFBXXXZZpXa-520-280.png',
      openurl : 'http://www.baidu.com'
    },{
      id : 2,
      url : 'https://aecpm.alicdn.com/imgextra/i4/240575018/O1CN01eSNp8b1mwI8iKklnI_!!240575018-0-alimamazszw.jpg',
      openurl : 'https://www.taobao.com/'
    },{
      id : 3,
      url : 'https://aecpm.alicdn.com/imgextra/i3/2137113794/O1CN01rW9Fzj1dthLx88imz_!!2137113794-0-alimamazszw.jpg',
      openurl : 'https://cn.vuejs.org/'
    }]
  }
  // console.log(data);
  res.send(data); //响应数据给前端
});



module.exports = Router; //导出主路由